package com.itdct.mto.core.listener;

import com.itdct.mto.core.config.MtoConfig;
import com.itdct.mto.core.service.MtoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * @author Zhouwx
 * @date 2025/7/1 14:53:35
 * @version 1.0
 * @description
 */
@Slf4j
@Component
public class AutoRunListener implements ApplicationListener<ContextRefreshedEvent> {
    @Autowired
    private MtoService mtoService;
    @Autowired
    private MtoConfig mtoConfig;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (!mtoConfig.isAutoRun()) {
            log.info("自动运行已关闭");
            return;
        }
        mtoService.fullConvert();
    }
}
